<html>

<head>

<?php

include "../includes/constants.php";
include "../includes/functions.php";
@include "../includes/profile.php";

if ($_GET["id"]) {
	echo "<title>EQ Emu - " . $Profile[name] . "'s Zone Flags</title>\n";
} else {echo "<title>EQ Emu - Zone Flags</title>\n";};

?>

</head>

<body>

<?php
if ($_GET[id]) {
?>

<table border="1">
	<tr>
		<td align="center">Zone</td>
		<td align="center">Title</td>
		<td align="center">Flagged</td>
	</tr>
<?php

// Get account status
$acct_status = mysql_result(mysql_query("SELECT status FROM account JOIN character_ ON character_.account_id = account.id WHERE character_.id='" . $_GET[id] . "'",$db),0,status);

/* $query = "SELECT 
	zone.short_name,
	zone.long_name
FROM zone 
JOIN zone_flags ON
	zone.zoneidnumber = zone_flags.zoneID
WHERE 
	zone.flag_needed != '' AND 
	zone.min_status <= '" . $acct_status . "'
ORDER BY zone.short_name ASC"; */
$query = "SELECT
	zone.short_name,
	zone.long_name,
	zone_flags.charID
FROM zone_flags
LEFT JOIN zone ON
	zone_flags.zoneID = zone.zoneidnumber
WHERE
	zone.flag_needed != '' AND 
	zone_flags.charID = '" . $_GET[id] . "'
ORDER BY zone.short_name ASC";
$result = mysql_query($query,$db);

if ($db_row = mysql_fetch_array($result)) {
	do {
?>
	<tr>
		<td><?php echo $db_row[short_name]?></td>
		<td><?php echo $db_row[long_name]?></td>
		<td align="center">Yes</td>
	</tr>
<?php
	} while ($db_row = mysql_fetch_array($result));
};

?>
</table>

<?php //echo "<pre>" . $query . "</pre>"?>

<?php
} else {
	echo "<form name=\"NoID\" method=\"GET\" action=\"\">Enter ID: <input type=\"text\" name=\"id\" size=\"2\"><br>\n";
};
?>


</body>

</html>